package org.geeks.controller;

import org.geeks.config.FTPConfig.FTPGateway;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件上传Controller
 * 
 * @author Geek4J
 *
 */
@RequestMapping("file")
@RestController
public class FileUploadController {

	@Autowired
	private FTPGateway gateway;

	/**
	 * 将上传文件通过FTP传输
	 * 
	 * @param file
	 *            上传文件
	 * @throws Exception
	 *             异常
	 */
	@PostMapping("/upload")
	public void handleFileUpload(@RequestParam("file") MultipartFile file) throws Exception {
		gateway.sendToFtp(file.getBytes());
	}
}
